package com.erp.purchase.controller;

import java.util.List;

import com.erp.purchase.domain.Product;
import com.erp.purchase.domain.PurOrderDTO;
import com.erp.purchase.service.IPurOrderAppendService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.erp.common.core.controller.BaseController;
import com.erp.common.core.domain.AjaxResult;

/**
 * 采购员信息：关联采购订单指派Controller
 *
 * @author hfw
 * @date 2025-09-02
 */
@RestController
@Slf4j
@RequestMapping("/purchase/order/append")
public class PurOrderAppendController extends BaseController
{
    @Autowired
    private IPurOrderAppendService purOrderAppendService;
    //查询商品分类
    @GetMapping("/getProductCategoryList")
    public AjaxResult getProductCategoryList()
    {
        List<String> list = purOrderAppendService.getProductCategoryList();
        return success(list);
    }
    //查询商品列表
    @GetMapping("/getProductList")
    public AjaxResult getProductList(@RequestParam(value = "productName", required = false) String productName)
    {
        List<Product> list = purOrderAppendService.getProductList(productName);
        return success(list);
    }
    //根据分类查询商品列表
    @GetMapping("/getProductListByCategory")
    public AjaxResult getProductListByCategory(@RequestParam("category") String category)
    {
        List<Product> list = purOrderAppendService.getProductListByCategory(category);
        return success(list);
    }
    //查询仓库名称
    @GetMapping("/getWarehouseList")
    public AjaxResult getWarehouseList()
    {
        List<String> list = purOrderAppendService.getWarehouseList();
        return success(list);
    }
    //添加采购订单
    @PostMapping("/order")
    public AjaxResult addOrder(@RequestBody PurOrderDTO purOrderDTO)

    {
        log.info("添加采购订单：{}", purOrderDTO);
        return toAjax(purOrderAppendService.addOrder(purOrderDTO));

    }



}
